#ifndef VECTOR_INFORMATION_CLASS
#define VECTOR_INFORMATION_CLASS
#pragma once
#include "framework.h"
/*
    1.向量:单行或者单列（一维数组,也可以称为标量的数组）
    2.单位向量：是指模等于1的向量。由于是非零向量，单位向量具有确定的方向。单位向量有无数个。
*/

// 向量信息描述类
class VectorInformation
{
private:
    double x = 0, y = 0, z = 0;
public:
    VectorInformation() {};
    VectorInformation(const VectorInformation& vd) :x(vd.x), y(vd.y), z(vd.z) {}
    VectorInformation(double x, double y, double z) :x(x), y(y), z(z) {}
    // 返回一个0向量
    void ZeroVectorDescription() { x = y = z = 0; }
    // [-]负向量
    VectorInformation operator-();
    // 向量与标量的乘法与除法运算
    VectorInformation operator*(double scalar);
    VectorInformation operator*=(double scalar);
    VectorInformation operator/(double scalar);
    VectorInformation operator/=(double scalar);
    // 计算向量平方根(向量的模),符号||a||表示a向量的平方根
    double SquareVectorDescription();
    // 打印向量
    void ShowVectorInformation();

    double GetX() { return x; }
    double GetY() { return y; }
    double GetZ() { return z; }

    // 向量[x,y,z]的标准化=[x/√￣(x^2+y^2+z^2),y/√￣(x^2+y^2+z^2),z/√￣(x^2+y^2+z^2)]
    void Normalize();

    // 向量与向量的加法减法运算
    VectorInformation operator+(VectorInformation ved);
    VectorInformation operator-(VectorInformation ved);
    VectorInformation operator+=(VectorInformation ved);
    VectorInformation operator-=(VectorInformation ved);
    // 向量点乘 a*b=a.x*b.x+a.y*b.y+a.z*b.z+a.n*b.n+...=||a||*||b||*cosθ
    double operator*(VectorInformation ved);
    VectorInformation operator*=(VectorInformation ved);
    /*
    向量点乘
    a*b|0                | angle is | a and b are
    ---|----------------|----------|------------------------------------------
    >0 |0° ≤ θ < 90°    | acute       | pointing mostly in the same direction
    0  |θ = 90°            | right       | perpendicular
    <0 |90° ≤ θ ≤ 180°    | obtuse   | pointing mostly in the opposite direction
    */
    // 向量叉乘
    // [x1] * [x2]       [y1*z2-z1*y2]
    // [y1] * [y2]    = [z1*x2-x1*z2]
    // [z1] * [z2]      [x1*y2-y1*x2]
};
VectorInformation operator* (int scalar, VectorInformation vecd);
// 获取两个向量点之间距离,公式:√￣(vecd1.x-vecd2.x)^2+(vecd1.y-vecd2.y)^2+(vecd1.z-vecd2.z)^2
double GetDistanceBetweenTwoVectorPoints(VectorInformation& vecd1, VectorInformation vecd2);
// 计算余铉角度
double GetCosAngle(VectorInformation& vecd1, VectorInformation vecd2);
// 计算向量叉乘
VectorInformation CrossMultiply(VectorInformation& vecd1, VectorInformation vecd2);


// 弧度转换为角度
inline double RadiansToAngles(double radian) {
    return radian * PI / 180;
}
// 格式化打印输出的浮点值
inline double FormatOutputFloatValue(double oValue) {
    // 绝对值过小则省略为0
    return ((abs(oValue) < 0.0000001) ? 0 : oValue);
}
#endif // !VECTOR_DESCRIPTION_CLASS

